#pragma once

#include <windows.h>

namespace avlib{
class AviFile;

class ScreenRecorder{
private:
	RECT m_region;
	unsigned short m_fps;
	HBITMAP m_bmp,m_old;
	HDC m_memdc;

	void * mp_bits;
	unsigned m_timer;

	bool init_bmp();

	HWND previewWnd;

	//CRITICAL_SECTION cs;
	AviFile *m_avi ;
public:

	
	ScreenRecorder();
	~ScreenRecorder();

	void set_param(unsigned short fps,bool full_screen = false);
	void set_region(LPRECT rect);
	void get_region(RECT & rect){
		rect = m_region;
	}

	void start(HWND hwnd,AviFile *avi);
	void stop();

	void blt();

	//HBITMAP get_bmp();
	void * get_bits();
	void release_bits();

};

};